package thread;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
//互斥锁
public class SyncDemo5 {
    public static void main(String[] args) {
        Boo boo = new Boo();
        Thread t1 = new Thread(boo::wayA);
        Thread t2 = new Thread(boo::wayB);
        t1.start();
        t2.start();

    }
}

class Boo{

    public void wayA(){
        try {
            System.out.println(Thread.currentThread()+"正在调用方法A");
            Thread.sleep(1000);
            System.out.println(Thread.currentThread()+"调用方法A结束");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    public void wayB(){
        try {
            System.out.println(Thread.currentThread()+"正在调用方法b");
            Thread.sleep(1000);
            System.out.println(Thread.currentThread()+"调用方法b结束");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
